<!--用户列表页面-->
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head >
    <meta charset="UTF-8">
    <title>Title</title>
    <!--静态路径-->
    <!-- <link rel="stylesheet" type="text/css" href="../../static/layuiadmin/layui/css/layui.css" media="all">
     <link rel="stylesheet" type="text/css" href="../../static/layuiadmin/style/admin.css" media="all">
     <script type="text/javascript" src="../../static/layuiadmin/layui/layui.js"></script>-->
    <link rel="stylesheet" type="text/css"th:href="@{/layuiadmin/layui/css/layui.css}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/layuiadmin/style/admin.css}" media="all">
    <script type="text/javascript" th:src="@{/layuiadmin/layui/layui.js}"></script>
    <style>
        .allView{
            text-align: center;
            font-size: 2em;
            line-height: 160px;
            color: #57a88b;

            border-radius: 5px;
        }
        .distance{
            border: 1px solid #e29f2a;
            margin-top: 20px;
            font-size: 1em;
            text-align: center;
            color: #070000;
        }
        .top{

            margin-top: -5%;
        }
        .text{
            background-color: rgb(255, 255, 251);
        }
        hr{
            width: 80%;
        }
        .p_hr{
            margin-top: 15px;
        }
        .right-text{
            text-align: center;
            margin-left: 20%;
            color: red;
        }

    </style>

</head>
<body>
<div class="layui-fluid">

    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">

                <div class="layui-card-header">用户列表</div>
                <div class="layui-card-body">
                    <div class=" layui-row-md6">
                        <table class="layui-hide" id="demo" lay-filter="demo"></table>
                    </div>

                </div>
            </div>
        </div>
    </div>

    <script type="text/html" id="barDemo">
        <a class="layui-btn  layui-btn-xs" lay-event="detail">重置密码</a>
       <!-- <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>-->
    </script>
</div>

<script>
    layui.use(['element','table','jquery','form'] ,function(){
        var element = layui.element,
            table = layui.table,
            form = layui.form,
            $= layui.$
        ;
        table.render({
            elem: '#demo'
            //,skin: 'line' //表格风格
            ,even: true
            ,page: true //是否显示分页
            ,limits: [2, 7, 10]
            ,limit: 10 //每页默认显示的数量
            ,url:'getCustAll'
            ,id: 'testReload'
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            ,cols: [
                [
                    {type:'checkbox'},
                    {field:'custId', width:'10%', title: '用户id', },
                    {field:'username', width:'10%', title: '用户名', },
                    {field:'custName', width:'10%', title: '用户账号', },
                    {field:'custLevel', width:'10%', title: '用户等级', },
                    {field:'sex', width:'10%', title: '用户性别', },
                    {field:'telNo', width:'10%', title: '用户手机号', },
                    {field:'zip', width:'10%', title: '用户邮编', },
                    { field: 'right',title: '操作',toolbar: "#barDemo",fixed: 'right'
                    }
                ]
            ]
            , response: {
                statusName: 'code',
                statusCode: '1',
                msgName: 'msg',
                countName: 'total',
                dataName: 'data'
            },  request: {
                pageName: 'currentPage', // 当前页
                limitName: 'pageSize' // 每页面显示多少条
            },
        });

        table.on('tool(demo)', function(obj) {
            var data = obj.data
            if (obj.event ==='detail'){
                $.ajax({
                    type:'post',
                    url:'resetPassword',
                    data:{custId:data.custId},
                    async:false,
                    //dataType:'json',
                    success:function (res) {
                        if (res.code==1 ){
                            layer.confirm('密码重置成功',{
                                title:'密码重置成功',
                                content:'新密码是123456',
                            })
                        }else{
                        }
                    }
                })
            }else if (obj.event ==='edit'){
              document.location.href =''
            }else if(obj.event==='del'){ //删除
                layer.confirm('确认删除',function(){
                    $.ajax({
                        type:"post",
                        url:'',
                        data:{id:data.id},
                        dataType:'json',
                        success:function (res) {
                            if (res.code == 1){
                                layer.msg(res.msg,{icon:6})
                            } else{
                                layer.msg(res.msg,{icon:5})
                            }
                        }
                    })
                })

            }
        })
        //…
        $('.addKind').on('click',function () {
            layer.open({
                title:'修改商品信息',
                type: 1,
                area:['400px','200px'],
                content:$('#dome')
            })
        })

    });
</script>
</body>
</html>